package amit.ui.table;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;


/**
 * 
 * @author ido
 * 
 */
public class AdTableRenderer extends DefaultTableCellRenderer{

	/**
	 * 
	 */
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {

		super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

		String val = value.toString();
		setText(val);	
		
		if (column == 1 || column == 2) {
			setHorizontalAlignment(SwingConstants.RIGHT);
		} else {
			setHorizontalAlignment(SwingConstants.LEFT);
		}
		 
		if (hasFocus){
			setBackground( Color.yellow );
		}
		else if (isSelected) {
			setBackground( table.getSelectionBackground() );
		}
		else {
			setBackground( table.getBackground() );
		}
		return this;

	}
}
